package handler

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"short_video/api/request"
	"short_video/internal/dao"
	"short_video/internal/model"
)

func RechargeOrder(c *gin.Context) {
	var req request.RechargeOrder

	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 10000,
			"msg":  "参数信息失败",
			"data": err.Error(),
		})
		return
	}
	userId := c.GetUint("userId")
	var user model.User
	dao.GetOneById(userId, &user)
	var order model.Order
	dao.Create(&model.Order{
		OrderNo: "105646134563",
		UserId:  userId,
		Money:   req.Money,
		Status:  1,
		Product: fmt.Sprintf("%s", order.Product),
	})
	c.JSON(http.StatusOK, gin.H{
		"code": http.StatusOK,
		"msg":  "充值成功",
		"data": true,
	})
}

func OrderDetailsOrder(c *gin.Context) {
	var req request.OrderDetailsOrder

	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 10000,
			"msg":  "参数信息失败",
			"data": err.Error(),
		})
		return
	}
	var order model.Order
	dao.GetOneById(req.Id, &order)
	if order.Id == 0 {
		c.JSON(http.StatusOK, gin.H{
			"code": 10000,
			"msg":  "订单详情失败",
			"data": nil,
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": http.StatusOK,
		"msg":  "订单详情成功",
		"data": order,
	})
}

func VipOrder(c *gin.Context) {

}
